/**
 * Created by wheat on 2018/8/16.
 */


import * as types from '../constants/loginType'; // 导入事件类别,用来做事件类别的判断

// 初始状态

const initialState = {
  status: '点击登录',
  isDone: false,
  user: null,
};

export default function loginIn(state=initialState, action) {

  switch (action.type) {

    case types.LOGIN_IN_DOING:

      return {
        ...state,
        status: '正在登陆',
        isDone: false,
        user: null,

      };
      break;

    case types.LOGIN_IN_DONE:

      return {
        ...state,
        status: '登陆成功',
        isDone: true,
        user: action.user,
      };
      break;

    case types.LOGIN_IN_ERROR:

      return {
        ...state,
        status: '登录出错',
        isDone: true,
        user: null,
      }

      break;
    default:

      return state;
  }
}